package cn.kongwg.service.impl;

import cn.kongwg.dao.BookMapper;
import cn.kongwg.entity.Books;
import cn.kongwg.service.BookService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kongwg
 * @create 2021-03-11 15:49
 */
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public Integer addBook(Books book) {
        return bookMapper.addBook(book);
    }

    @Override
    public Integer deleteBook(Integer id) {
        return bookMapper.deleteBook(id);
    }

    @Override
    public Integer updateBook(Books book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public Books findBookById(Integer id) {
        return bookMapper.findBookById(id);
    }

    @Override
    public List<Books> findAllBook() {
        return bookMapper.findAllBook();
    }

    @Override
    public List<Books> queryBookByName(String bookName) {
        return bookMapper.queryBookByName(bookName);
    }

    @Override
    public PageInfo<Books> pageBook(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Books> allBook = bookMapper.findAllBook();
        return new PageInfo<>(allBook);
    }
}
